﻿
        $(function () {
            $.post("../BLL/City.ashx", { "action": "GetCityLists" }, function (data, status) {
                if (status == "success") {
                    var city = $.parseJSON(data);
                    //$("#city").empty();
                    for (var i = 0; i < city.length; i++) {
                        var value = city[i].SelfCode;
                        var name = city[i].Name;
                        var option = '<option value=' + value + '>' + name + '</option>';
                        $("#city").append(option);
                    }
                }
            });
            $("#city").change(function () {
                var name = $(this).find('option:selected').text();
                $("#cityName").val(name);
                var cityCode = $(this).val();
                $("#HidCity").val(cityCode);
                $.post("../BLL/County.ashx", { "action": "GetCountyList", "cityCode": cityCode }, function (data, status) {
                    if (status == "success") {
                        var county = $.parseJSON(data);

                        $("#county").empty();
                        var opt = '<option value=' + '' + '>' + ' 请选择所属县区 ' + '</option>';
                        $("#county").append(opt);
                        for (var i = 0; i < county.length; i++) {
                            var name = county[i].Name;
                            var selfCode = county[i].SelfCode;
                            var option = '<option value=' + selfCode + ' >' + name + '</option>';
                            $("#county").append(option);
                        }
                    }
                });
            });

            $("#county").change(function () {
                $("#HidCounty").val($(this).val());
                var name = $(this).find('option:selected').text();
                $("#countyName").val(name);
            });


            //检查用户名是否存在
            $("#txtUserName").focusout(function () {
                var username = $(this).val();
                $.post("../Bll/UsersAsh.ashx", { "action": "IsUserName", "username": username }, function (data, status) {
                    if (status == "success") {
                        var result = data;
                        if (result == "ok") {
                            $("#lbUserName").html("该用户已存在");
                            $("#txtUserName").focus();
                            return;
                        }
                    }
                });
            });

        });      

